package org.dromara.work.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.TreeBuildUtils;
import org.dromara.work.domain.BaseDmlb;
import org.dromara.work.mapper.BaseDmlbMapper;
import org.dromara.work.service.IBaseDmlbService;
import org.springframework.stereotype.Service;
import org.dromara.work.domain.bo.BaseDmlbBo;
import org.dromara.work.domain.vo.BaseDmlbVo;
import java.util.List;
import java.util.Map;

/**
 * 地名分类Service业务层处理
 *
 * @author Chen
 * @date 2024-02-25
 */
@RequiredArgsConstructor
@Service
public class BaseDmlbServiceImpl implements IBaseDmlbService {

    private final BaseDmlbMapper baseMapper;


    @Override
    public List<BaseDmlbVo> queryList(BaseDmlbBo bo) {
        LambdaQueryWrapper<BaseDmlb> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<BaseDmlb> buildQueryWrapper(BaseDmlbBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<BaseDmlb> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getName()), BaseDmlb::getName, bo.getName());
        lqw.like(bo.getCode()!=null, BaseDmlb::getCode, bo.getCode());
        lqw.like(bo.getParentId()!=null, BaseDmlb::getParentId, bo.getParentId());
        lqw.orderByAsc(BaseDmlb::getCode);
        return lqw;
    }


}
